home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles Flirt Up Your Life! (German)
/
Singles Flirt Up Your Life.iso
/
data1.cab
/
Statemachine
/
easelChar.lua
< prev
next >
Wrap
Text File
|
2004-01-29
|
3KB
|
103 lines
-- easel character state machine
beginStateMachine()
onEnter(function(msg)
local easel = getStateObjectFromID(msg.sender);
storeStateObject("easel", easel);
if (easel) then
-- easel does exist
if (getParent().isOneActionPointLocked(easel)) then
-- action point is locked
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
else
getParent().lockActionPoints(easel);
end
else
-- easel does not exist anymore
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
end
freeHands(getParent());
end )
onExit(function(msg)
-- local easel = retrieveStateObject("easel");
-- getParent().unlockActionPoints(easel);
-- getParent().stopAllActivities(easel);
-- removeStateObject("easel");
unlockAll("easel");
end )
state("paint")
onEnter(function(msg)
local brush = getParent().loadGameObject("StandardGO","paintbrush");
storeStateObject("brush", brush);
getParent().attachRightObjectHolder(brush);
local palette = getParent().loadGameObject("StandardGO","palette");
storeStateObject("palette", palette);
getParent().attachLeftObjectHolder(palette);
local easel = retrieveStateObject("easel");
startAnimation("paint");
local paintActivity = getParent().startActivity("paint", easel);
local length, scale = getActivityLength(paintActivity);
-- this.actionComplete();
sendDelayedMsgThis("stopPainting", length);
sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
end )
onMsg("stopPainting", function(msg)
getParent().detachRightObjectHolder();
local brush = retrieveStateObject("brush");
if (brush) then brush.deleteGameObject(); end
getParent().detachLeftObjectHolder();
local palette = retrieveStateObject("palette");
if (palette) then palette.deleteGameObject(); end
local easel = retrieveStateObject("easel");
getParent().stopActivity("paint", easel);
exitStateMachine();
end )
-- onMsg("queue", function(msg)
-- sendMsgThis("stopPainting");
-- end )
onMsg("testCancel", function(msg)
if testCancel() and (not this.getParent().getCurrentActivityGain()) then
sendMsgThis("stopPainting");
else
sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
end
end )
onMsg("end", function(msg)
if testCancel() then
sendMsgThis("stopPainting");
else
startAnimation("paint");
end
end )
endStateMachine()